package com.qfedu.food.service.impl;


import com.github.pagehelper.PageHelper;
import com.qfedu.food.dao.TFoodDao;
import com.qfedu.food.dto.PageDto;
import com.qfedu.food.dto.TFoodDto;
import com.qfedu.food.pojo.TFood;
import com.qfedu.food.service.intf.TFoodService;
import com.qfedu.food.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class TFoodServiceImpl implements TFoodService {

    @Autowired(required = false)
    private TFoodDao dao;
    @Override
    public R selectFoodAll() {
        return R.ok(dao.selectFoodAll());
    }

    @Override
    public R selectFoodById(long id) {
        return R.ok(dao.selectFoodById(id));
    }

    @Override
    public R selectFoodAllPage(PageDto dto) {
            String m=dto.getMsg();
            if(m!=null && m.length()>0){
                m="%"+m+"%";
            }
            PageHelper.startPage(dto.getPage(),dto.getSize());
            return R.ok(dao.selectFoodAllPage(m));
        }
}
